﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.WindowsAzure.StorageClient;
using Microsoft.WindowsAzure;
using Microsoft.WindowsAzure.Diagnostics.Management;

namespace MyLib
{
    public class clsContext
    {
        private  CloudBlobClient _myCloudBlobClient = null;
        public  CloudBlobClient MyCloudBlobClient
        {
            get
            {
                if (_myCloudBlobClient == null)
                {
                    _myCloudBlobClient = MyCloudStorageAccount.CreateCloudBlobClient();
                }
                return _myCloudBlobClient;
            }
        }

        private CloudStorageAccount _myCloudStorageAccount = null;
        public CloudStorageAccount MyCloudStorageAccount
        {
            get
            {
                if (_myCloudStorageAccount == null)
                {
                    var sa = MyClsStorageAccount;
                    var storageCredentialsAccountAndKey = new StorageCredentialsAccountAndKey(sa.StorageName, sa.StorageKey);
                    _myCloudStorageAccount = new CloudStorageAccount(storageCredentialsAccountAndKey, true);
                }
                return _myCloudStorageAccount;
            }
        }

        private clsStorageAccount _myclsStorageAccount = null;
        public clsStorageAccount MyClsStorageAccount
        {
            get
            {
                if (_myclsStorageAccount == null)
                {
                    _myclsStorageAccount = clsStorageAccount.GetStorageAccount();
                }
                return _myclsStorageAccount;
            }
        }

        private MyDiagnosticManager _myDDM = null;
        public MyDiagnosticManager MyDDM
        {
            get
            {
                if (_myDDM == null)
                {
                    var sa = MyClsStorageAccount;
                    _myDDM = MyDiagnosticManager.GetMyDiagnosticManager(sa.StorageName, sa.StorageKey,sa.DeploymentID);
                }
                return _myDDM;
            }
        }
        


    }
}
